﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing {
    import flash.events.*;
    import org.aswing.event.*;
    import org.aswing.util.*;
    import org.aswing.plaf.basic.*;

    public class JProgressBar extends Component implements Orientable {

        public static const HORIZONTAL:int = 0;
        public static const VERTICAL:int = 1;

        private var orientation:int;
        private var indeterminate:Boolean;
        private var string:String;
        private var model:BoundedRangeModel;
        private var indeterminatePaintTimer:Timer;
        private var indeterminateDelaySet:Boolean;

        public function JProgressBar(_arg1:int=0, _arg2:int=0, _arg3:int=100){
            setName("ProgressBar");
            this.orientation = _arg1;
            this.model = new DefaultBoundedRangeModel(_arg2, 0, _arg2, _arg3);
            this.addListenerToModel();
            this.indeterminate = false;
            this.string = null;
            this.indeterminateDelaySet = false;
            this.indeterminatePaintTimer = new Timer(40);
            this.indeterminatePaintTimer.addActionListener(this.__indeterminateInterval);
            addEventListener(Event.ADDED_TO_STAGE, this.__progressAddedToStage);
            addEventListener(Event.REMOVED_FROM_STAGE, this.__progressRemovedFromStage);
            this.updateUI();
        }
        override public function updateUI():void{
            setUI(UIManager.getUI(this));
        }
        override public function getDefaultBasicUIClass():Class{
            return (BasicProgressBarUI);
        }
        override public function getUIClassID():String{
            return ("ProgressBarUI");
        }
        public function setIndeterminateDelay(_arg1:uint):void{
            this.indeterminatePaintTimer.setDelay(_arg1);
            this.setIndeterminateDelaySet(true);
        }
        public function getIndeterminateDelay():uint{
            return (this.indeterminatePaintTimer.getDelay());
        }
        public function setIndeterminateDelaySet(_arg1:Boolean):void{
            this.indeterminateDelaySet = _arg1;
        }
        public function isIndeterminateDelaySet():Boolean{
            return (this.indeterminateDelaySet);
        }
        public function getModel():BoundedRangeModel{
            return (this.model);
        }
        public function setModel(_arg1:BoundedRangeModel):void{
            if (this.model != null){
                this.model.removeStateListener(this.__onModelStateChanged);
            };
            this.model = _arg1;
            if (this.model != null){
                this.addListenerToModel();
            };
        }
        public function getString():String{
            return (this.string);
        }
        public function setString(_arg1:String):void{
            if (this.string != _arg1){
                this.string = _arg1;
                repaint();
            };
        }
        public function getOrientation():int{
            return (this.orientation);
        }
        public function setOrientation(_arg1:int):void{
            if (((!((_arg1 == HORIZONTAL))) && (!((_arg1 == VERTICAL))))){
                _arg1 = HORIZONTAL;
            };
            if (this.orientation != _arg1){
                this.orientation = _arg1;
                revalidate();
                repaint();
            };
        }
        public function getPercentComplete():Number{
            var _local1:int = (this.model.getMaximum() - this.model.getMinimum());
            var _local2:int = this.model.getValue();
            var _local3:Number = ((_local2 - this.model.getMinimum()) / _local1);
            return (_local3);
        }
        public function getValue():int{
            return (this.getModel().getValue());
        }
        public function getMinimum():int{
            return (this.getModel().getMinimum());
        }
        public function getMaximum():int{
            return (this.getModel().getMaximum());
        }
        public function setValue(_arg1:int):void{
            this.getModel().setValue(_arg1);
        }
        public function setMinimum(_arg1:int):void{
            this.getModel().setMinimum(_arg1);
        }
        public function setMaximum(_arg1:int):void{
            this.getModel().setMaximum(_arg1);
        }
        public function setIndeterminate(_arg1:Boolean):void{
            this.indeterminate = _arg1;
            this.__validateIndeterminateIntervalIfNecessary();
        }
        public function isIndeterminate():Boolean{
            return (this.indeterminate);
        }
        private function addListenerToModel():void{
            this.model.addStateListener(this.__onModelStateChanged);
        }
        private function __progressAddedToStage(_arg1:Event):void{
            this.__validateIndeterminateIntervalIfNecessary();
        }
        private function __progressRemovedFromStage(_arg1:Event):void{
            this.__validateIndeterminateIntervalIfNecessary();
        }
        private function __onModelStateChanged(_arg1:InteractiveEvent):void{
            repaint();
        }
        private function __indeterminateInterval(_arg1:AWEvent):void{
            repaint();
        }
        private function __validateIndeterminateIntervalIfNecessary():void{
            if (((this.isIndeterminate()) && (isOnStage()))){
                if (!this.indeterminatePaintTimer.isRunning()){
                    this.indeterminatePaintTimer.start();
                };
            } else {
                if (this.indeterminatePaintTimer.isRunning()){
                    this.indeterminatePaintTimer.stop();
                };
            };
        }

    }
}//package org.aswing 
